<?php
$user = "root";
$pwd = "root";
$dsn = "mysql:host=localhost;dbname=exam";
$db = new PDO($dsn, $user, $pwd);
$db->query('set names utf8');
$result = $db->query('select * from exam0');
$result->setFetchMode(PDO::FETCH_ASSOC);
$insert = $db->prepare("update exam0 set time=:time, place=:place, teacher=:teacher where course=:course AND class=:class");
while ($row = $result->fetch()) {
	$name = $row['course'];
	$class = $row['class'];
	$plcae0 = $name . "+" . $class . "+" . "place0";
	$plcae1 = $name . "+" . $class . "+" . "place1";
	$PLACE = $_POST[$plcae0] . $_POST[$plcae1];
	$time0 = $name . "+" . $class . "+" . "time0";
	$time1 = $name . "+" . $class . "+" . "time1";
	$Time = $_POST[$time0] . " " . $_POST[$time1];
	$teacher = $name . "+" . $class . "+" . "teacher";
	$TEACHER = $_POST[$teacher];
	$insert->execute(array(':time' => $Time, ':place' => $PLACE, ':teacher' => $TEACHER, ':course' => $name, ':class' => $class));
}
header("location:slecet.php");
?>